#include<reg51.h>
#include<intrins.h>

#define GPIO_DIG   P0	
#define GPIO_PLACE P1	


unsigned char code DIG_CODE[17] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

unsigned char DisplayData[8]={0};

int time=0,LedNumVal_1=9990;

void DigDisplay(); 
void time0_init();



void main(void)
{
	
  time0_init();
	while(1)
	{
		 DisplayData[0]=LedNumVal_1%10000/1000;
     DisplayData[1]=LedNumVal_1%1000/100;	 
     DisplayData[2]=LedNumVal_1%100/10;
     DisplayData[3]=LedNumVal_1%10;

		 DigDisplay();
		 
	}				
}


void DigDisplay()
{
	unsigned char i;
	unsigned int j;
  unsigned char temp=0xef;
	for(i=0; i<8; i++)
	{
		GPIO_DIG = 0x00;
		GPIO_DIG = DIG_CODE[DisplayData[i]];  
		GPIO_PLACE=temp;
		temp = _crol_(temp,1);
    j=50;		
    while(j--);
	}
}


void time0_init()
{
    EA=1;
	  TMOD = 0x01; 
	  TH0 = (65536 - 50000)/256;
	  TL0 = (65536- 50000)%256	;
	  ET0=1;
    TR0=1;    
}


 /*************************************
 [ T0 (1ms)??] ??

*************************************/
void time0(void) interrupt 1      //3???1????  1???0???? 0????1 2????2  4????
{
	 
	 TH0 = (65536 - 50000)/256	;
	 TL0 = (65536 - 50000)%256;
	 time++;
   if(time==20)
 	 {   
		 LedNumVal_1++;
		 time=0;
	 }
}